package com.example.provider.controller;

import com.example.common.entity.Ad;
import com.example.common.entity.Message;
import com.example.provider.service.AdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 
 *
 * @author zxm
 * @email 1625012165@qq.com
 * @date 2020-09-11 13:56:45
 */
@RestController
@Slf4j
@Api(value = "广告controller", tags = {"广告相关接口"})
@RequestMapping("/ad")
public class AdController {
    @Autowired
    private AdService adService;

    @ApiOperation("发送广告位申请，哪个角色申请的service层去判断")
    @PostMapping("/addAd")
    @ResponseBody
    public Message addAd(@RequestBody Ad ad){
        return adService.addAd(ad);
    }

    @ApiOperation("管理员查找全部广告")
    @GetMapping("/findAllAd")
    public List<Ad> findAd(){
        return adService.findAd();
    }

    @ApiOperation("管理员上架广告")
    @ResponseBody
    @PostMapping("/upAd")
    public Message upAd(@RequestBody Ad ad){
        return adService.upAd(ad);
    }

    //轮播图查找正上架的广告
    @GetMapping("/findAding")
    public List<Ad> findAding(){
        return  adService.findAding();
    }

    @ApiOperation("管理员删除已在上架的广告")
    @ResponseBody
    @PostMapping("/deleteAding")
    public Message deleteAding(@RequestBody Ad ad){
        return  adService.deleteAding(ad);
    }

    @ApiOperation("企业或工作室查看广告申请状态")
    @ResponseBody
    @PostMapping("/checkAdStatus")
    public List<Ad> checkAdStatus(@RequestBody Ad ad){
        return  adService.checkAdStatus(ad);
    }

}
